﻿using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Collections;

namespace OpenComposite.Workflow.Design
{
	internal class PropertyValueProviderTypeConverter : TypeConverter
	{
		public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
		{
			IPropertyValueProvider provider = null;
			object[] inst = context.Instance as object[];
			if ( inst != null && inst.Length > 0 ) {
				provider = inst[0] as IPropertyValueProvider;
			} else {
				provider = context.Instance as IPropertyValueProvider;
			}
			ICollection values = new object[0];
			if ( provider != null ) {
				values = provider.GetPropertyValues(context);
			}
			return new StandardValuesCollection(values);
		}
		public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
		{
			return true;
		}
		public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
		{
			return true;
		}
	}

	internal interface IPropertyValueProvider
	{
		ICollection GetPropertyValues(ITypeDescriptorContext context);
	}
}
